﻿using HelixToolkit.Wpf.SharpDX.Animations;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using WpfModelEditor.Core.Plugins;

namespace ViewPlugin
{
    /// <summary>
    /// AnimationPanel.xaml 的交互逻辑
    /// </summary>
    public partial class AnimationPanel
    {
        private IHost Host { get; set; }
        public AnimationPanel()
        {
            InitializeComponent();
        }
        public AnimationPanel(IHost host)
        {
            InitializeComponent();
            Host = host;
        }
        public void Update()
        {
            list.ItemsSource = Host.Animations;
        }
        private void list_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (!e.Handled && e.ChangedButton == MouseButton.Left && sender is ListBoxItem lbi)
            {
                Host.SelectedAnimation = lbi.Content as IAnimationUpdater;
                Host.StartAnimation();
            }
        }
    }
}
